
R3F_FNCT_Homed = {
	private ["_group","_radius","_arraywp","_wptype","_array","_z","_p","_array_pos",
	"_inside_pos","_posz","_pos","_index","_nbrinside","_i","_count","_units","_unit","_wp","_random","_return"];
	_group = _this select 0;
	_return = false;
	if (typeName _group != "GROUP") exitWith {_return};
	_radius = _this select 1;
	if (typeName _radius != "SCALAR") exitWith {_return};
	if (count _this > 2) then {
		_arraywp = _this select 2;
	} else {
		_wptype = "HOLD";
	};
	if (!(isNil "_arraywp") && (typeName _arraywp != "ARRAY")) exitWith {_return};
	_array = nearestObjects [_group,["house"],_radius];
	if (count _array == 0) exitWith {_return};
	_array_pos = [];
	_z = 0;
	{	_p = 0;
		while {_inside_pos = _x buildingPos _p; format ["%1",_inside_pos] != "[0,0,0]"} do {
			_array_pos set [count _array_pos,_inside_pos];
			_posz = _inside_pos select 2;
			if (_posz > _z) then {
				_z = _posz;
				_pos = _inside_pos;
				_index = count _array_pos + _p;
			};
			_p = _p + 1;
		};
	} forEach _array;
	if (count _array_pos == 0) exitWith {_return};
	if (count (units _group) == 1) exitWith {
		_index = floor (random (count _array_pos));
		_pos = _array_pos select _index;
		_wp = _group addWaypoint [_pos,0];
		_wp setWaypointType "HOLD";
		_wp setWaypointBehaviour "COMBAT";
		_wp setWaypointCombatMode "RED";
		true
	};
	_count = (count (units _group)) min (count _array_pos);
	_count = _count - 1;
	for "_i" from _count to 0 step - 1 do {
		_units = units _group;
		_unit = _units select _i;
		if (_unit == vehicle _unit) then {
			if (count _units > 1) then {
				[_unit] joinSilent grpNull;
			};
			_wp = (group _unit) addWaypoint [_pos,0];
			if !(isNil "_arraywp") then {
				_random = floor (random (count _arraywp));
				_wptype = _arraywp select _random;
				if !(_wptype in ["HOLD","SENTRY","GUARD"]) then {_wptype = "HOLD";};
			};
			_wp setWaypointType _wptype;
			_wp setWaypointBehaviour "COMBAT";
			_wp setWaypointCombatMode "RED";
			if ((side _unit != civilian) && _i == _count) then {
				[_unit] spawn {
					sleep 60;
					private "_unit";
					_unit = _this select 0;
					if (alive _unit) exitWith {
						_unit setunitPos "Middle";
						_unit setSkill ["general",0.9];
					};
				};
			};
			_array_pos = [_array_pos,_index] call BIS_fnc_removeIndex;
			_index = floor (random (count _array_pos));
			_pos = _array_pos select _index;
		};
	};
	if (count (units _group) == 1) then {_return = true;};
	_return
};
